// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "PawnBase.generated.h"

UCLASS()
class SNAKE_API APawnBase : public APawn
{
	GENERATED_BODY()

public:
	// Sets default values for this pawn's properties
	APawnBase();

	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<class ASnakeBase> SnakeActorClass;

	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<class AFoodGeneratorBase> FoodGeneratorClass;

	UPROPERTY(EditDefaultsOnly)
	FVector FoodGeneratorPositionCell = {0, 0, 0};
	
	UPROPERTY(BlueprintReadWrite)
	class ASnakeBase* SnakeActor = nullptr;

	UPROPERTY(BlueprintReadWrite)
	class AFoodGeneratorBase* FoodGeneratorActor = nullptr;
	
protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

	void CreateSnakeActor();

	void CreateFoodGeneratorActor();

	UFUNCTION()
	void HandlePlayerVerticalInput(float Value);

	UFUNCTION()
	void HandlePlayerHorizontalInput(float Value);

	UFUNCTION(BlueprintCallable)
	void RunSnake();

	UFUNCTION(BlueprintCallable)
	ASnakeBase* GetSnake();

	UFUNCTION(BlueprintCallable)
	AFoodGeneratorBase* GetFoodGenerator();
};
